package com.chaochis.wind.user.service.impl;

import com.chaochis.wind.common_exceptions.has_delete_exception.UserHasTombstoneException;
import com.chaochis.wind.constant.DatabaseInfoNullDefault;
import com.chaochis.wind.enums.AccountType;
import com.chaochis.wind.enums.DataStatus;
import com.chaochis.wind.user.mapper.WindAccountMapper;
import com.chaochis.wind.user.service.WindAccountService;
import com.chaochis.wind.user.service.WindUserService;
import com.chaochis.wind.user.vo.WindAccount;
import com.chaochis.wind.user.vo.WindUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service("windAccountService")
public class WindAccountServiceImpl implements WindAccountService {

  @Autowired
  protected WindAccountMapper windAccountMapper;

  @Autowired
  protected WindUserService windUserService;

  /**
   * 获取所有的登录账户
   * @param windAccount 要查询的参数
   * @return 返回查询到的登录账户
   */
  @Override
  public List<WindAccount> getWindAccountList(WindAccount windAccount) {
    return this.windAccountMapper.getAccountList(windAccount);
  }

  @Override
  public WindAccount getWindAccountByAccountName(String accountName, AccountType accountType) {
    return this.windAccountMapper.getAccountByAccountName(accountName, accountType);
  }

  @Override
  public WindAccount getWindAccountDetailByAccountId(String accountId) {
    return this.windAccountMapper.selectById(accountId);
  }

  @Override
  public WindUser getBoundWindUser(String accountId) {
    return this.windAccountMapper.getBoundUser(accountId);
  }

  @Override
  public void addWindAccount(WindAccount windAccount) {
    this.windAccountMapper.insert(windAccount);
  }

  @Override
  public void updateWindAccount(WindAccount windAccount) {
    this.windAccountMapper.updateById(windAccount);
  }

  @Override
  public void deleteWindAccount(String accountId) {
    this.windAccountMapper.deleteById(accountId);
    var bindWindUser = this.windAccountMapper.getBoundUser(accountId);
  }
}
